package com.hpu.service;

import android.content.Context;
import android.os.Handler;

import com.hpu.callback.UploadHeadImageCallback;
import com.hpu.constants.HttpConstants;
import com.hpu.constants.ShareConstants;
import com.hpu.constants.UrlConstants;
import com.hpu.tools.InternetTools;
import com.hpu.tools.OkHttpTools;
import com.hpu.tools.ShareTools;

import java.io.File;
import java.util.HashMap;

/**
 * 最新公告业务类，获取40条最新公告的标题与id
 * @author Administrator
 *
 */
public class UploadHeadImageService{

	private Handler handler;
	
	private Context context;
	
	public UploadHeadImageService(Handler handler,Context context) {
		this.handler=handler;
		this.context=context;
	}
	
	public void uploadImage(File file) {
		HashMap<String, Object> map=new HashMap<>();
		map.put("personal_image",file);
		if(InternetTools.statusInternet(context)==InternetTools.NO_INTERNET)
			handler.sendEmptyMessage(HttpConstants.NO_INTERNET);
		else
			
		OkHttpTools.upLoadFile(UrlConstants.INTERFACE_UPLOAD_HEAD_IMAGE,
				ShareTools.get(context, ShareConstants.STORE_LOGINCOOKIE, "").toString(),
				map,
				new UploadHeadImageCallback(handler));
	}

}

